package com.ycsj.goldmedalnewconcept;

import cn.magicwindow.MWConfiguration;
import cn.magicwindow.MagicWindowSDK;

import com.tencent.mm.sdk.openapi.IWXAPI;
import com.tencent.mm.sdk.openapi.WXAPIFactory;
//import com.umeng.analytics.MobclickAgent;
import com.ycsj.goldmedalnewconcept.activity.ClassThirdActivity;
import com.ycsj.goldmedalnewconcept.activity.WelcomeActivity;
import com.ycsj.goldmedalnewconcept.utils.SPUtil;
import com.ycsj.goldmedalnewconcept.R;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;

//引导页
public class SplashActivity extends Activity {
	private String account;
	private String role;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_splash);
		
				//魔窗
//		MWConfiguration config = new MWConfiguration(this);
//		config.setLogEnable(true)//打开魔窗Log信息
//		//  .setPageTrackWithFragment(true)//是否统计Fragment页面
//		//  .setCustomWebViewTitleBarOn()//代码内定义webview标题
//		    .setSharePlatform(MWConfiguration.ORIGINAL);
//		MagicWindowSDK.initSDK(config);
		
		IWXAPI wxapi = WXAPIFactory.createWXAPI(SplashActivity.this,
				"wxdc431c56dc658787",true);
		wxapi.registerApp("wxdc431c56dc658787");
//		IWXAPI wxapi = WXAPIFactory.createWXAPI(SplashActivity.this,
//				"wx87beee1b911fdac7",true);
//		wxapi.registerApp("wx87beee1b911fdac7");
		
		MWConfiguration config = new MWConfiguration(this);
        config.setLogEnable(true);//打开魔窗Log信息
        MagicWindowSDK.initSDK(config);
		
		Intent intent = new Intent();
		int RunCount = SPUtil.getInt(this, "RUN_COUNT", 0);
		//如果是初次进去App就跳转到欢迎页面
		if (RunCount == 0) {
			RunCount++;
			SPUtil.putInt(this, "RUN_COUNT", RunCount);
			//引导页面
			intent.setClass(SplashActivity.this, WelcomeActivity.class);
			startActivity(intent);
			//转场动画
			overridePendingTransition(R.anim.push_up_in, R.anim.push_up_out);
			finish();
			return;
		} 
		
		//获取账号和用户角色类型
		account = SPUtil.getString(this, "account", "");
		role = SPUtil.getString(this, "role", "");
		if ("4".equals(role)||"".equals(role)) {
			//如果是游客角色或者没有登录过的其它角色,则跳转到身份选择页面
			intent.setClass(SplashActivity.this, StartActivity.class); //身份选择页
		}else {
			//如果是登录过的非游客角色,直接跳转到软件选择页面
			intent.setClass(SplashActivity.this, ButtonActivity.class);//软件选择页
		}
		
		startActivity(intent);
		overridePendingTransition(R.anim.push_up_in, R.anim.push_up_out);
		finish();
	}
	@Override
	protected void onResume() {
		// TODO Auto-generated method stub
		super.onResume();
//		MobclickAgent.onResume(this);
	}
	@Override
	protected void onPause() {
		// TODO Auto-generated method stub
		super.onPause();
//		MobclickAgent.onPause(this);
	}
}








